﻿--
-- Dropping stored procedure pr_DM_SU_KIEN_SelectAll : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_DM_SU_KIEN_SelectAll]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_DM_SU_KIEN_SelectAll]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_DM_SU_KIEN_SelectAll
-- Author:	MinhNN
-- Create date:	5/27/2012 3:24:44 PM
-- Description:	This stored procedure is intended for selecting all rows from DM_SU_KIEN table
-- ==========================================================================================
Create Procedure pr_DM_SU_KIEN_SelectAll
As
Begin
	Select 
		[ID],
		[ID_LOAI_SU_KIEN],
		[TEN_SU_KIEN],
		[NGAY_DIEN_RA],
		[ID_TRANG_THAI],
		[MO_TA]
	From DM_SU_KIEN
End

GO


--
-- Dropping stored procedure pr_DM_SU_KIEN_SelectRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_DM_SU_KIEN_SelectRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_DM_SU_KIEN_SelectRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_DM_SU_KIEN_SelectRow
-- Author:	MinhNN
-- Create date:	5/27/2012 3:24:44 PM
-- Description:	This stored procedure is intended for selecting a specific row from DM_SU_KIEN table
-- ==========================================================================================
Create Procedure pr_DM_SU_KIEN_SelectRow
	@ID numeric
As
Begin
	Select 
		[ID],
		[ID_LOAI_SU_KIEN],
		[TEN_SU_KIEN],
		[NGAY_DIEN_RA],
		[ID_TRANG_THAI],
		[MO_TA]
	From DM_SU_KIEN
	Where
		[ID] = @ID
End

GO


--
-- Dropping stored procedure pr_DM_SU_KIEN_Insert : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_DM_SU_KIEN_Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_DM_SU_KIEN_Insert]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_DM_SU_KIEN_Insert
-- Author:	MinhNN
-- Create date:	5/27/2012 3:24:44 PM
-- Description:	This stored procedure is intended for inserting values to DM_SU_KIEN table
-- ==========================================================================================
Create Procedure pr_DM_SU_KIEN_Insert
	@ID_LOAI_SU_KIEN numeric(18,0),
	@TEN_SU_KIEN nvarchar(250),
	@NGAY_DIEN_RA datetime,
	@ID_TRANG_THAI numeric(18,0),
	@MO_TA nvarchar(250)
As
Begin
	Insert Into DM_SU_KIEN
		([ID_LOAI_SU_KIEN],[TEN_SU_KIEN],[NGAY_DIEN_RA],[ID_TRANG_THAI],[MO_TA])
	Values
		(@ID_LOAI_SU_KIEN,@TEN_SU_KIEN,@NGAY_DIEN_RA,@ID_TRANG_THAI,@MO_TA)

	Declare @ReferenceID int
	Select @ReferenceID = @@IDENTITY

	Return @ReferenceID

End

GO


--
-- Dropping stored procedure pr_DM_SU_KIEN_Update : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_DM_SU_KIEN_Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_DM_SU_KIEN_Update]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_DM_SU_KIEN_Update
-- Author:	MinhNN
-- Create date:	5/27/2012 3:24:44 PM
-- Description:	This stored procedure is intended for updating DM_SU_KIEN table
-- ==========================================================================================
Create Procedure pr_DM_SU_KIEN_Update
	@ID numeric(18,0),
	@ID_LOAI_SU_KIEN numeric(18,0),
	@TEN_SU_KIEN nvarchar(250),
	@NGAY_DIEN_RA datetime,
	@ID_TRANG_THAI numeric(18,0),
	@MO_TA nvarchar(250)
As
Begin
	Update DM_SU_KIEN
	Set
		[ID_LOAI_SU_KIEN] = @ID_LOAI_SU_KIEN,
		[TEN_SU_KIEN] = @TEN_SU_KIEN,
		[NGAY_DIEN_RA] = @NGAY_DIEN_RA,
		[ID_TRANG_THAI] = @ID_TRANG_THAI,
		[MO_TA] = @MO_TA
	Where		
		[ID] = @ID

End

GO


--
-- Dropping stored procedure pr_DM_SU_KIEN_DeleteRow : 
--

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[pr_DM_SU_KIEN_DeleteRow]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[pr_DM_SU_KIEN_DeleteRow]
  
GO

-- ==========================================================================================
-- Entity Name:	pr_DM_SU_KIEN_DeleteRow
-- Author:	MinhNN
-- Create date:	5/27/2012 3:24:45 PM
-- Description:	This stored procedure is intended for deleting a specific row from DM_SU_KIEN table
-- ==========================================================================================
Create Procedure pr_DM_SU_KIEN_DeleteRow
	@ID numeric(18,0)
As
Begin
	Delete DM_SU_KIEN
	Where
		[ID] = @ID

End

GO
